package com.itheima.streamdemo;

import java.util.*;
import java.util.stream.Stream;

public class StreamDemo2 {
    public static void main(String[] args) {

        // 集合拿stream流
        Collection<String> names = new ArrayList<>();
        names.add("张三");
        names.add("李四");
        names.add("王五");
        names.add("赵六");
        Stream<String> stream = names.stream();

        // Map拿stream流，需要先拿到keySet()，再拿到stream流
        Map<String, Integer> map = new HashMap<>();
        map.put("张三", 18);
        map.put("李四", 19);
        map.put("王五", 20);
        map.put("赵六", 21);
        // 获取键值对流
        Stream<Map.Entry<String, Integer>> stream1 = map.entrySet().stream();
        // 获取键流
        Stream<String> stream2 = map.keySet().stream();
        // 获取值流
        Stream<Integer> stream3 = map.values().stream();


        // 拿到数组的stream流
        String [] arr = {"张三", "李四", "王五", "赵六"};
        Stream<String> stream4 = Stream.of(arr);
        Stream<String> stream5 = Stream.of("张三", "李四", "王五", "赵六");
        Stream<String> stream6 = Arrays.stream(arr);

   }
}
